<?php

namespace app\model\basic;

use app\model\TimeModel;

class Smscode extends TimeModel
{
    protected $table = 'sj_smscode' ;
    public static function checkCode($number , $code )
    {
        $time = time() + 900 ;
        $data = self::where('mobile' , $number)
            ->where('check_status' , 1)
            ->where('create_time' , '<' , $time)->order('id desc')->find() ;
        if($data['code'] === $code)
        {
            return true ;
        }
        return false ;
    }
    public static function clerkCode($number)
    {
        self::where('mobile' , $number)->update([
            'check_status' => 9 ,
            'check_time' => time() ,
        ]) ;
    }
}